/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: app2022 - RegExp2
 * <p>Powered by webrx On 2022-01-13 14:57:33
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class RegExp2 {
    public static void main(String[] args) {
        String s = "java23424mysql22html5user  book=student  --- Teacher--DEMO";
        Pattern p = Pattern.compile("[a-zA-Z]+");
        Matcher m = p.matcher(s);
        int i = 0;
        while(m.find()){
            System.out.printf("%d = %s%n",++i,m.group());
        }
        System.out.println("-".repeat(50));
        System.out.println(Arrays.toString( s.split("[^a-zA-Z]+")));
        System.out.println("-".repeat(50));


        s = """
                /*
                 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
                 *
                 */
                package cn;

                import java.util.Arrays;
                import java.util.regex.Matcher;
                import java.util.regex.Pattern;

                /**
                 * <p>Project: app2022 - RegExp2
                 * <p>Powered by webrx On 2022-01-13 14:57:33
                 *
                 * @author webrx [webrx@126.com]
                 * @version 1.0
                 * @since 17
                 */
                public class RegExp2 {
                    public static void main(String[] args) {
                        String s = "java23424mysql22html5user  book=student  --- Teacher--DEMO";
                        Pattern p = Pattern.compile("[a-zA-Z]+");
                        Matcher m = p.matcher(s);
                        int i = 0;
                        while(m.find()){
                            System.out.printf("%d = %s%n",++i,m.group());
                        }
                        System.out.println("-".repeat(50));
                        System.out.println(Arrays.toString( s.split("[^a-zA-Z]+")));
                        System.out.println("-".repeat(50));
                       \s
                       \s
                        s = ""\"
                               \s
                                ""\";
                        System.out.println("-".repeat(50));
                        i = 0;
                        for(String ts : s.split("[^a-zA-Z]+")){
                            System.out.printf("%d = %s%n",++i,ts);
                        }
                    }
                }

                                """;
        System.out.println("-".repeat(50));
        i = 0;
        var p2 = Pattern.compile("[a-zA-Z]{3,}", Pattern.MULTILINE);
        var m2 = p2.matcher(s);
        while(m2.find()){
            System.out.printf("%d = %s%n",++i,m2.group());
        }
    }
}
